package cn.com.open.itembank.common.enums;

/**
 * Created by lucky on 2017/7/17.
 */

/**
 * 章节类型
 */
public enum ChapterType {
    /**
     * 课程（根节点）
     */
    COURSE(0),
    /**
     * 章（默认）
     */
    CHAPTER(1),
    /**
     * 节
     */
    SECTION(2),
    /**
     * 知识点
     */
    KNOWLEDGEPOINT(3);

    private Integer index;

    ChapterType(Integer idx) {
        this.index = idx;
    }

    /**
     * Gets index.
     *
     * @return the index
     */
    public Integer getIndex() {
        return index;
    }

    public static ChapterType fromValue(Integer v) {
        for (ChapterType c : ChapterType.values()) {
            if (c.getIndex() == v) {
                return c;
            }
        }
        return null;
    }
}
